<?php /* Smarty version Smarty-3.1.8, created on 2012-04-02 01:54:15
         compiled from "./templates/index.tpl" */ ?>
<?php /*%%SmartyHeaderCode:7813899084f5e7593ea7ce6-02094947%%*/if(!defined('SMARTY_DIR')) exit('no direct access allowed');
$_valid = $_smarty_tpl->decodeProperties(array (
  'file_dependency' => 
  array (
    'c0360d049dff10f364dfc53ba2cc3958abf6ee6d' => 
    array (
      0 => './templates/index.tpl',
      1 => 1333324452,
      2 => 'file',
    ),
  ),
  'nocache_hash' => '7813899084f5e7593ea7ce6-02094947',
  'function' => 
  array (
  ),
  'version' => 'Smarty-3.1.8',
  'unifunc' => 'content_4f5e7594035e47_82042169',
  'variables' => 
  array (
    'HeaderJS' => 0,
    'MapJS' => 0,
    'username' => 0,
    'OnLoad' => 0,
    'Map' => 0,
    'messages' => 0,
    'message' => 0,
    'locations' => 0,
    'comments' => 0,
    'comment' => 0,
  ),
  'has_nocache_code' => false,
),false); /*/%%SmartyHeaderCode%%*/?>
<?php if ($_valid && !is_callable('content_4f5e7594035e47_82042169')) {function content_4f5e7594035e47_82042169($_smarty_tpl) {?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
                <meta http-equiv="Content-Language" content="hr" />
		<title>Terenac</title>
                <?php echo $_smarty_tpl->tpl_vars['HeaderJS']->value;?>

                <?php echo $_smarty_tpl->tpl_vars['MapJS']->value;?>

		<link rel="stylesheet" href="css/style.css" type="text/css" />
                <script type="text/javascript"
                src="./jquery/jquery-1.7.1.js"></script>
                <script type="text/javascript" src="./js/jquery.lightbox-0.5.js"></script>
                <link rel="stylesheet" type="text/css" href="./css/jquery.lightbox-0.5.css" media="screen" />
                <script type="text/javascript">
                                            
                                                    
function showComments(comments) {
var currentTime = new Date()
var month = currentTime.getMonth() + 1
var day = currentTime.getDate()
var year = currentTime.getFullYear()
var currentTime = new Date()
var hours = currentTime.getHours()
var minutes = currentTime.getMinutes()
if (minutes < 10){
minutes = "0" + minutes
}
if (month< 10){
month = "0" + month
}
    var display = year+'-'+month+'-'+day+' '+hours+':'+minutes+':' + currentTime.getSeconds();      
  $("#commentList"+comments.messageId).append(
'<li class="comments" id="comment'+comments.commentId + '"><b>'+comments.username+': </b>'+comments.text+' '+display+
'<a id="deleteComment-'+comments.commentId+'" class="deleteComment" href=""><img src="images/delete-icon.png" /></a></li>'
);
}
 
function  showAllComments(message) {
    $("#showComments" + message).show();
}
function deleteMessage(message) {
    $("#message" + message.messageId).hide();
}
function deleteComment(comment) {
    console.log(comment.commentId);
    $("#comment" + comment.commentId).hide();
}  
function addComment(messageId, username) {
    var text = $("#commentbox"+messageId).val();   
    var params = {text: text, username: username, messageId: messageId};     
    $.post('./ajaxPHP/addComment.php', params,
      showComments);   
}

$(document).ready(function() {
  $(".allComments").hide();
  //$("#map").hide();
  $(".linkShowComments").click(function () {
    $("#showCommentsMessage"+this.id.split('-')[1]).show("slow");           
    $("#"+this.id).hide();
    return false;
});
    $("#mapShow").click(function () { 
    $("#mapShow").html('<a id="mapHide" href="" >Hide map...</a>');
    $("#map").show('slow');
    return false;
});
    $("#mapHide").click(function () {
        if ($("#mapHide").attr("mapHidden") == "1") {            
                $("#mapHide").html('<a id="mapHide" mapHidden="0" href="" >Hide map...</a>');           
                $("#mapHide").attr("mapHidden","0");
                $("#map").show('slow');                                    
}
    else {        
        $("#mapHide").html('<a id="mapHide" mapHidden="1" href="" >Show map...</a>');
       $("#mapHide").attr("mapHidden","1");
        $("#map").hide('slow');
}
    //$("#mapHide").html('<a id="mapShow" href="" >Show map...</a>');    
    return false;
});
$(".deleteMessage").click(function (){
     var params = {messageId: this.id.split('-')[1]};          
    $.post('./ajaxPHP/deleteMessage.php', params,
      deleteMessage);
          return false;             
});
$(".deleteComment").click(function (){
    console.log("deletecomment called");    
     var params = {commentId: this.id.split('-')[1]};
    console.log(params.commentId);
    $.post('./ajaxPHP/deleteComment.php', params,
      deleteComment);
          return false;             
});    
});
    $(function() {
        $('.gallery').lightBox();
    });    
    
                                </script>        
	</head>
	<body>
		<div class="page">
			<div class="header">
				<a href="index.php" id="logo"><img src="images/logo1.png" alt="Terenac"/></a>
				<ul>
					<li><a href="index.php">Home</a></li>
                                        <li><a href="sparkweb/SparkWeb.html">Chat</a></li>
					<li class="selected"><a href="settings.php"><?php echo $_smarty_tpl->tpl_vars['username']->value;?>
</a></li>
                                        
					<li><a href="logout.php">Logout</a></li>
				</ul>
			</div>
			<div class="body" >                           
                                          <table class="mapa">
                                              <tr><td>
                                                  <a id="mapHide" mapHidden="0" href="" >Hide map...</a>
                                                  </td></tr>
                                            <tr><td>
                                            <?php echo $_smarty_tpl->tpl_vars['OnLoad']->value;?>

                                            <?php echo $_smarty_tpl->tpl_vars['Map']->value;?>

                                            
                                            </td></tr>
                                           </table>
                                             <ul>
                                    <?php  $_smarty_tpl->tpl_vars['message'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['message']->_loop = false;
 $_smarty_tpl->tpl_vars['k'] = new Smarty_Variable;
 $_from = $_smarty_tpl->tpl_vars['messages']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
foreach ($_from as $_smarty_tpl->tpl_vars['message']->key => $_smarty_tpl->tpl_vars['message']->value){
$_smarty_tpl->tpl_vars['message']->_loop = true;
 $_smarty_tpl->tpl_vars['k']->value = $_smarty_tpl->tpl_vars['message']->key;
?>
                                       
                                    <li id="message<?php echo $_smarty_tpl->tpl_vars['message']->value['ID'];?>
">
						<div class="featured" >
                                                   
                                                    <a class="gallery" href="image.php?image=<?php echo $_smarty_tpl->tpl_vars['message']->value['PictureID'];?>
&size=full"><img src="image.php?image=<?php echo $_smarty_tpl->tpl_vars['message']->value['PictureID'];?>
&size=thumb" alt=""/></a>
                                                        
						</div>                                               
						<div>
                                                    <h3><?php echo $_smarty_tpl->tpl_vars['message']->value['Username'];?>
 <?php echo $_smarty_tpl->tpl_vars['message']->value['Time'];?>
</h3>
                                                    <p><?php echo $_smarty_tpl->tpl_vars['locations']->value[$_smarty_tpl->tpl_vars['message']->value['ID']];?>
</p>
                                                    <p><?php ob_start();?><?php echo $_smarty_tpl->tpl_vars['message']->value['Username'];?>
<?php $_tmp1=ob_get_clean();?><?php ob_start();?><?php echo $_smarty_tpl->tpl_vars['username']->value;?>
<?php $_tmp2=ob_get_clean();?><?php if ($_tmp1==$_tmp2){?>
                                                        <a id="deleteMessage-<?php echo $_smarty_tpl->tpl_vars['message']->value['ID'];?>
" class="deleteMessage" href=""><img src="images/delete-icon.png" /></a>
                                                        <?php }?>
                                                    </p>
							<p><?php echo $_smarty_tpl->tpl_vars['message']->value['Comment'];?>
</p>
                                                        <a class="linkShowComments" id="linkShowComments-<?php echo $_smarty_tpl->tpl_vars['message']->value['ID'];?>
" href="" ><h4 id="showComments<?php echo $_smarty_tpl->tpl_vars['message']->value['ID'];?>
" class="showComments" >Show comments...</h4></a>
                                                        <div class="allComments" id="showCommentsMessage<?php echo $_smarty_tpl->tpl_vars['message']->value['ID'];?>
" >
                                                            <h4 id="comm">Comments...</h4>
                                                            <ul id="commentList<?php echo $_smarty_tpl->tpl_vars['message']->value['ID'];?>
">
                                                                <?php  $_smarty_tpl->tpl_vars['comment'] = new Smarty_Variable; $_smarty_tpl->tpl_vars['comment']->_loop = false;
 $_smarty_tpl->tpl_vars['k'] = new Smarty_Variable;
 $_from = $_smarty_tpl->tpl_vars['comments']->value[$_smarty_tpl->tpl_vars['message']->value['ID']]; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array');}
foreach ($_from as $_smarty_tpl->tpl_vars['comment']->key => $_smarty_tpl->tpl_vars['comment']->value){
$_smarty_tpl->tpl_vars['comment']->_loop = true;
 $_smarty_tpl->tpl_vars['k']->value = $_smarty_tpl->tpl_vars['comment']->key;
?>
                                                                <li class="comments" id="comment<?php echo $_smarty_tpl->tpl_vars['comment']->value['ID'][1];?>
"><b><?php echo $_smarty_tpl->tpl_vars['comment']->value['Username'];?>
: </b><?php echo $_smarty_tpl->tpl_vars['comment']->value['text'];?>
 <?php echo $_smarty_tpl->tpl_vars['comment']->value['time'];?>

                                                        <?php ob_start();?><?php echo $_smarty_tpl->tpl_vars['comment']->value['Username'];?>
<?php $_tmp3=ob_get_clean();?><?php ob_start();?><?php echo $_smarty_tpl->tpl_vars['username']->value;?>
<?php $_tmp4=ob_get_clean();?><?php if ($_tmp3==$_tmp4){?>
                                                        <a id="deleteComment-<?php echo $_smarty_tpl->tpl_vars['comment']->value['ID'][1];?>
" class="deleteComment" href=""><img src="images/delete-icon.png" /></a>
                                                        <?php }?>                                                                
                                                               
                                                                </li>
                                                                 <?php } ?>
                                                            </ul>
                                                            <ul>
                                                                <li id="comm_li">                                                                    
                                                                <input id="commentbox<?php echo $_smarty_tpl->tpl_vars['message']->value['ID'];?>
" name="comment" type="text" onfocus="this.value=''" value="Write a comment..."  />
                                                                <input class="button" id="comm_submit" type="submit" value="Comment" onclick="addComment('<?php echo $_smarty_tpl->tpl_vars['message']->value['ID'];?>
', '<?php echo $_smarty_tpl->tpl_vars['username']->value;?>
')"/>                                                                
                                                                </li>
                                                            </ul>
                                                        </div>                                                               
						</div>                                                
					</li>
                                    <?php } ?>
				</ul>				
			</div>
			<div class="footer">
				<p class="paragraphcenter">&#169; Copyright &#169; 2012. Terenac all rights reserved</p>
			</div>
		</div>

	</body>
</html>  <?php }} ?>